﻿using System;
using DevExpress.Xpo;

namespace Aij1.Model
{
    /// <summary>
    /// 订单
    /// </summary>
    public class B_Order : XPObject
    {
        public B_Order(Session session)
            : base(session)
        {
            // This constructor is used when an object is loaded from a persistent storage.
            // Do not place any code here.
        }

        public override void AfterConstruction()
        {
            base.AfterConstruction();
            // Place here your initialization code.
        }

        string fOrderNo;
        /// <summary>
        /// 订单号 S120506001
        /// </summary>
        [Indexed(Unique=true), Size(10)]
        public string OrderNo
        {
            get { return fOrderNo; }
            set { SetPropertyValue<string>("OrderNo", ref fOrderNo, value); }
        }

        C_Customer fCustomerId;
        public C_Customer CustomerId
        {
            get { return fCustomerId; }
            set { SetPropertyValue<C_Customer>("CustomerId", ref fCustomerId, value); }
        }

        DateTime fOrderTime;
        public DateTime OrderTime
        {
            get { return fOrderTime; }
            set { SetPropertyValue<DateTime>("OrderTime", ref fOrderTime, value); }
        }

        ProcessStatusType fProgress;
        public ProcessStatusType Progress
        {
            get { return fProgress; }
            set { SetPropertyValue<ProcessStatusType>("Progress", ref fProgress, value); }
        }
        
        [Association("O-I"), Aggregated]
        public XPCollection<B_OrderItem> Items
        {
            get { return GetCollection<B_OrderItem>("Items"); }
        }

        int fPayable;
        /// <summary>
        /// 应付款项
        /// </summary>
        public int Payable
        {
            get { return fPayable; }
            set { SetPropertyValue<int>("Payable", ref fPayable, value); }
        }

        int fNetpay;
        /// <summary>
        /// 实付款项
        /// </summary>
        public int Netpay
        {
            get { return fNetpay; }
            set { SetPropertyValue<int>("Netpay", ref fNetpay, value); }
        }

        //Guid fOrderId;
        //[Indexed(Unique = true)]
        //public Guid OrderId
        //{
        //    get { return fOrderId; }
        //    set { SetPropertyValue<Guid>("OrderId", ref fOrderId, value); }
        //}
    }

}